﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        $("#SchoolType").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "SchoolType" }
        });
        if (null != keyValue && "" != keyValue) {
            $.ajax({
                url: "/Gas/School/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        } else {
            initControl();
        }
    });
    function initControl() {
        $.ajax({
            url: "/Gas/School/GetMaxSortId",
            dataType: "json",
            async: false,
            success: function (data) {
                $("#SortId").val(data); //新增时,初始化排序号
            }
        });
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/Gas/School/SubmitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <th class="formTitle">学校账号</th>
                <td class="formValue">
                    <input id="SchoolAccount" name="SchoolAccount" type="text" class="form-control required" placeholder="请输入学校账号" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">学校名称</th>
                <td class="formValue">
                    <input id="SchoolName" name="SchoolName" type="text" class="form-control required" placeholder="请输入学校名称" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">年级类型</th>
                <td class="formValue">
                    <select id="SchoolType" name="SchoolType" style="height:20px" class="form-control required"></select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">学校密码</th>
                <td class="formValue">
                    <input id="SchoolPwd" name="SchoolPwd" type="text" class="form-control required" placeholder="请输入学校密码" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">是否租房可见</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="isRent" name="isRent" type="checkbox" checked="checked"><label for="isRent">有效</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序号</th>
                <td class="formValue">
                    <input id="SortId" name="SortId" type="text" class="form-control required" placeholder="排序号"/>
                </td>
            </tr>
        </table>
    </div>
</form>
